package com.java.dormitorymanager.mvc.view;

import com.java.dormitorymanager.pojo.Manager;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

/**
 * @program: DormitoryManager
 * @description: 超级管理员界面
 * @author: ShuangChenYue
 * @create: 2021-05-14 20:30
 **/
@WebServlet(value = "/ViewSuperManager")
public class ViewSuperManagerServlet extends HttpServlet
{
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException
    {
        doPost(req,resp);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException
    {
        System.out.println("通过超级管理员登录操作进入该ViewSuperManager");
        req.setCharacterEncoding("utf-8");
        resp.setContentType("text/html");
        resp.setCharacterEncoding("utf-8");
        PrintWriter out = resp.getWriter();

        out.println("<!DOCTYPE html>");
        out.println("<html lang=\"en\">");
        out.println("<head>");
        out.println("<meta charset=\"UTF-8\">");
        out.println("<title>超级管理员</title>");
        out.println("<link rel=\"stylesheet\" type=\"text/css\" href=\"http://localhost:8080/DormitoryManager/css/css-manager/superManager.css\">");
        out.println("<link rel=\"stylesheet\" type=\"text/css\" href=\"http://localhost:8080/DormitoryManager/css/css-other/doIcon.css\">");
        out.println("<script type=\"text/javascript\">function toManageCommonManager(){window.open('http://localhost:8080/DormitoryManager/mvc/ManageCommonManager.do','_blank')}</script>");
        out.println("<script type=\"text/javascript\">function toManageStudent(){window.open('http://localhost:8080/DormitoryManager/mvc/ManageStudentManager.do','_blank')}</script>");
        out.println("<script type=\"text/javascript\">function toManageDorm(){window.open('http://localhost:8080/DormitoryManager/mvc/ManageDorm.do','_blank')}</script>");
        out.println("</head>");
        out.println("<body>");
        out.println("<div id=\"divTitle\">");
        out.println("<h1 id=\"h01\">Super Manager</h1>");
        out.println("</div>");
        out.println("<div id=\"divSM\">");
        Manager superManager = (Manager) req.getAttribute("superManager");
        out.println("<a id=\"SMIcon\" class=\"iconfontU\" href=\"/DormitoryManager/ViewSuperManagerDetail\" title=\"超级管理员\" target=\"_blank\">&#xe600;：<span id=\"SMName\">"+superManager.getName()+"</span></a>");
        out.println("</div>");
        out.println("<div id=\"divContainer\">");
        out.println("<table>");
        out.println("<tr>");
        out.println("<td>");
        out.println("<div id=\"div01\" title=\"管理寝室管理员\" onclick=\"toManageCommonManager()\">");
        out.println("<a id=\"a01\">Dorm Manager</a> ");
        out.println("</div>");
        out.println("</td>");
        out.println("<td>");
        out.println("<div id=\"div02\" title=\"管理学生\" onclick=\"toManageStudent()\">");
        out.println("<a id=\"a02\" href=\"#\">Student</a>");
        out.println("</div>");
        out.println("</td>");
        out.println("<td>");
        out.println("<div id=\"div03\" title=\"管理寝室\" onclick=\"toManageDorm()\">");
        out.println("<a id=\"a03\" href=\"#\">Dormitory</a>");
        out.println("</div>");
        out.println("</td>");
        out.println("</tr>");
        out.println("</table> ");
        out.println("</div>");
        out.println("</body>");
        out.println("</html>");
        out.flush();
        out.close();
    }
}
